<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:insert="~{include :: header('专业列表')}" />
    <th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<body class="hold-transition">
<div class="container-fluid mb-2">
    <div class="btn-group" id="toolbar" role="group">
        <a class="btn btn-success" id="btn-subject-add">
            <i class="fa fa-plus"></i> 添加
        </a>
    </div>
    <div class="select-table table-striped">
        <table id="bootstrap-table" class="table-striped"></table>
    </div>
</div>
<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: bootstrap-table-js}" />
<script th:inline="javascript">
    var prefix = "/subject";

    $(function() {
        var options = {
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            url: prefix + "/list.json",
            createUrl: prefix + "/add.html",
            removeUrl: prefix + "/remove.json",
            modalName: "专业",
            columns: [
                {
                    field: 'subjectId',
                    width:100,
                    title: 'id'
                },
                {
                    field: 'subjectName',
                    title: '专业名称'
                },
                {
                    field: 'sort',
                    width:150,
                    align: 'center',
                    title: '排序'
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    width:200
                },
                {
                    title: '操作',
                    align: 'center',
                    width:250,
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="subjectEdit(\'' + row.subjectId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.subjectId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

        //添加书籍
        $('#btn-subject-add').click(function (){
            $.modal.open("新增专业", prefix + "/edit.html","600px","300px");
        })
    });

    function subjectEdit(id) {
        $.modal.open("新增专业", prefix + "/edit.html?id="+id,"600px","300px");
    }
</script>
</body>
</html>